package com.overseasShopping.Base.DAOImpl;

import java.util.List;

import com.overseasShopping.Base.DAO.OrderListDAO;
import com.overseasShopping.pojo.OrderList;

public class OrderListDAOImpl extends BaseDAOImpl<OrderList> implements OrderListDAO{
	
	public List<OrderList> getUserIdList(String buyUserId, String saleUserId) {
		String hql = "from OrderList where buyUser.userId=? or saleUser.userId=? order by data desc";
		Object[] params={buyUserId,saleUserId};
		List<OrderList> orderLists = getHibernateTemplate().find(hql,params);
		return orderLists;
		
	}

	public List<OrderList> getBuyUserIdList(String buyUserId) {
		String hql = "from OrderList where buyUser.userId=? order by data desc";
		List<OrderList> orderLists = getHibernateTemplate().find(hql,buyUserId);
		return orderLists;
	}

	public List<OrderList> getSaleUserIdList(String saleUserId) {
		String hql = "from OrderList where saleUser.userId=? order by data desc";
		List<OrderList> orderLists = getHibernateTemplate().find(hql,saleUserId);
		return orderLists;
	}

	public List<OrderList> getStateList(int state) {
		String hql = "from OrderList where state=? order by data desc";
		List<OrderList> orderLists = getHibernateTemplate().find(hql,state);
		return orderLists;
	}

	public List<OrderList> getBuyStateList(int state, String buyUserId) {
		String hql = "from OrderList where buyUser.userId=? and state=? order by data desc";
		Object[] params={buyUserId,state};
		List<OrderList> orderLists = getHibernateTemplate().find(hql,params);
		return orderLists;
	}

	public List<OrderList> getSaleStateList(int state, String saleUserId) {
		String hql = "from OrderList where saleUser.userId=? and state=? order by data desc";
		Object[] params={saleUserId,state};
		List<OrderList> orderLists = getHibernateTemplate().find(hql,params);
		return orderLists;
	}

	public void addOrder(OrderList order) {
		getHibernateTemplate().save(order);
	}

	public OrderList getOrder(String orderId) {
		// TODO Auto-generated method stub
		return null;
	}

	

}
